def file_len(fname):
    with open(fname) as f:
        for i, l in enumerate(f):
            pass
    return i + 1

def dice(line):
	word = ""
	dice = []
	for i in range(len(line)):
		if line[0:1] != "d":
			word = word + line[0:1]
			
		if line[0:1] == "d" or len(line) == 1:
			try:
				word = int(word)
				dice.append(word)
			except:
				pass
			
			word = ""
		
		line = line[1:]
	
	return(dice)

def parse( line, divider): #find entries in line before divider, return as right type.
	word = ""
	entries = []
	
	
	for i in range(len(line)):
		if divider == "|":
			if line[0:1] != divider and line[0:1] != " ":
				word = word + line[0:1]
		else:
			if line[0:1] != divider:
				word = word + line[0:1]
				
		if line[0:1] == divider or len(line) == 1:
			try:
				word = int(word)
			except:
				pass
			entries.append(word)
			word = ""
		line = line[1:]
		
	
	return(entries)